#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<assert.h>
#include<string.h>

const char* my_strstr(const char* str1, const char* str2)
{
	assert(str1 && str2);
	const char* s1 = NULL;
	const char* s2 = NULL;
	const char* cur = str1;
	if (*str2 == '\0')
	{
		return cur;
	}
	while (cur)
	{
		s1 = cur;
		s2 = str2;
		while (s1 && s2 && *s1 == *s2)
		{
			s1++;
			s2++;
			size_t len1 = strlen(s1);
			size_t len2 = strlen(s2);
			if (len1 < len2)
			{
				return NULL;
			}
			/*if (*s1 == '\0')
			{
				return NULL;
			}*/
		}
		if (*s2 == '\0')
		{
			return cur;
		}
		cur++;
	}
	return NULL;
}

int main()
{
	char arr[] = "huanggghongyu";
	char* p = "hongyu";
	const char* ret = my_strstr(arr, p);
	printf("%s\n", ret);
	return 0;
}